
package com.haiheng.voiceandbook.receiver
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.util.Log
import com.haiheng.voiceandbook.MainActivity
import java.util.*

/**
 * 开机启动广播
 */
class BootRestartReceiver : BroadcastReceiver() {
    val ACTION = "android.intent.action.BOOT_COMPLETED"
    val TAG = "BootRestartReceiver"
    override fun onReceive(context: Context?, intent: Intent?) {
        Log.e(TAG, "开机启动........ ")
        val task: TimerTask = object : TimerTask() {
            override fun run() {
                val intent2 = Intent(context, MainActivity::class.java)
                intent2.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
                context!!.startActivity(intent2)
            }
        }
        val time = Timer()
        time.schedule(task,30000)


    }
}